﻿using System;
using System.Collections.Generic;

using System.Text;

namespace System.Qizx.Xml
{
    /*******************************/
    /// <summary>
    /// This class provides the base implementation for the management of XML documents parsing.
    /// </summary>
    public class XmlSaxDefaultHandler : XmlSaxContentHandler, XmlSaxErrorHandler, XmlSaxEntityResolver
    {
        /// <summary>
        /// This method manage the notification when Characters element were found.
        /// </summary>
        /// <param name="ch">The array with the characters founds</param>
        /// <param name="start">The index of the first position of the characters found</param>
        /// <param name="length">Specify how many characters must be read from the array</param>
        public virtual void characters(char[] ch, int start, int length)
        {
        }

        /// <summary>
        /// This method manage the notification when the end document node were found
        /// </summary>
        public virtual void endDocument()
        {
        }

        /// <summary>
        /// This method manage the notification when the end element node were found
        /// </summary>
        /// <param name="namespaceURI">The namespace URI of the element</param>
        /// <param name="localName">The local name of the element</param>
        /// <param name="qName">The long name (qualify name) of the element</param>
        public virtual void endElement(string uri, string localName, string qName)
        {
        }

        /// <summary>
        /// This method manage the event when an area of expecific URI prefix was ended.
        /// </summary>
        /// <param name="prefix">The prefix that ends</param>
        public virtual void endPrefixMapping(string prefix)
        {
        }

        /// <summary>
        /// This method manage when an error exception ocurrs in the parsing process
        /// </summary>
        /// <param name="exception">The exception throws by the parser</param>
        public virtual void error(System.Xml.XmlException e)
        {
        }

        /// <summary>
        /// This method manage when a fatal error exception ocurrs in the parsing process
        /// </summary>
        /// <param name="exception">The exception Throws by the parser</param>
        public virtual void fatalError(System.Xml.XmlException e)
        {
        }

        /// <summary>
        /// This method manage the event when a ignorable whitespace node were found
        /// </summary>
        /// <param name="Ch">The array with the ignorable whitespaces</param>
        /// <param name="Start">The index in the array with the ignorable whitespace</param>
        /// <param name="Length">The length of the whitespaces</param>
        public virtual void ignorableWhitespace(char[] ch, int start, int length)
        {
        }

        /// <summary>
        /// This method is not supported only is created for compatibility
        /// </summary>
        public virtual void notationDecl(string name, string publicId, string systemId)
        {
        }

        /// <summary>
        /// This method manage the event when a processing instruction were found
        /// </summary>
        /// <param name="target">The processing instruction target</param>
        /// <param name="data">The processing instruction data</param>
        public virtual void processingInstruction(string target, string data)
        {
        }

        /// <summary>
        /// Allow the application to resolve external entities.
        /// </summary>
        /// <param name="publicId">The public identifier of the external entity being referenced, or null if none was supplied.</param>
        /// <param name="systemId">The system identifier of the external entity being referenced.</param>
        /// <returns>A XmlSource object describing the new input source, or null to request that the parser open a regular URI connection to the system identifier.</returns>
        public virtual XmlSource resolveEntity(string publicId, string systemId)
        {
            return null;
        }

        /// <summary>
        /// This method is not supported, is include for compatibility
        /// </summary>		 
        public virtual void setDocumentLocator(XmlSaxLocator locator)
        {
        }

        /// <summary>
        /// This method manage the event when a skipped entity were found
        /// </summary>
        /// <param name="name">The name of the skipped entity</param>
        public virtual void skippedEntity(string name)
        {
        }

        /// <summary>
        /// This method manage the event when a start document node were found 
        /// </summary>
        public virtual void startDocument()
        {
        }

        /// <summary>
        /// This method manage the event when a start element node were found
        /// </summary>
        /// <param name="namespaceURI">The namespace uri of the element tag</param>
        /// <param name="localName">The local name of the element</param>
        /// <param name="qName">The Qualify (long) name of the element</param>
        /// <param name="atts">The list of attributes of the element</param>
        public virtual void startElement(string uri, string localName, string qName, SaxAttributesSupport attributes)
        {
        }

        /// <summary>
        /// This methods indicates the start of a prefix area in the XML document.
        /// </summary>
        /// <param name="prefix">The prefix of the area</param>
        /// <param name="uri">The namespace uri of the prefix area</param>
        public virtual void startPrefixMapping(string prefix, string uri)
        {
        }

        /// <summary>
        /// This method is not supported only is created for compatibility
        /// </summary>        
        public virtual void unparsedEntityDecl(string name, string publicId, string systemId, string notationName)
        {
        }

        /// <summary>
        /// This method manage when a warning exception ocurrs in the parsing process
        /// </summary>
        /// <param name="exception">The exception Throws by the parser</param>
        public virtual void warning(System.Xml.XmlException e)
        {
        }
    }
}
